package com.wiscamp.ninechapters.problems.domain.models.problems.answers;


import com.wiscamp.ninechapters.problems.enums.AnswerTypes;
import com.wiscamp.ninechapters.problems.math.LatexDecimalSeries;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 小数序列答案
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class DecimalSeriesAnswer extends Answer {
    /**
     * 答案值
     */
    private LatexDecimalSeries value;

    public DecimalSeriesAnswer(long answerId, long questionId, int answerIndex, int groupIndex, LatexDecimalSeries value) {
        setAnswerType(AnswerTypes.DECIMAL_SERIES);
        this.value = value;
        setAnswerId(answerId);
        setQuestionId(questionId);
        setAnswerIndex(answerIndex);
        setGroupIndex(groupIndex);
        setAnswerTypeId(this.getAnswerType().getValue());
    }

    @Override
    public String getAnswerText() {
        //this.setContentHypertext(value.getLatex());
        return value.getLatex();
    }

    /*@Override
    public boolean compareAnswer(String contentText) {
        var valueTexts = contentText.split(",");
        if (valueTexts.length != value.getValues().size())
            return false;

        var sheetAnswerValues = new ArrayList<BigDecimal>();
        for (var text : valueTexts)
        {
            sheetAnswerValues.add(ParseUtils.parseBigDecimal(text));
        }

        for (var correctValue : value.getValues()) {
            var hasValue = false;
            for (var sheetAnswerValue : sheetAnswerValues) {
                if (sheetAnswerValue == correctValue)
                    hasValue = true;
            }
            if (!hasValue) return false;
        }
        return true;
    }*/
}
